function HotelCtrl($scope, $http, $location,$route) {


    function prepareHabitaciones(){
        var rows = $('[name="row"]'),
            habitaciones = [];
        var count= 0;
        _.each($(rows), function(row){
            if(row.getElementsByClassName("id")[0]){
                var id = row.getElementsByClassName("id")[0].value;
                var nombre = row.getElementsByClassName("nombre")[0].value;
                var cMinima = row.getElementsByClassName("cMinima")[0].value;
                var cMaxima = row.getElementsByClassName("cMaxima")[0].value;
                if(id && nombre && cMinima && cMaxima){
                    count++;
                    habitacion = {};
                    habitacion.id = id;
                    habitacion.nombre = nombre;
                    habitacion.cMinima = cMinima;
                    habitacion.cMaxima = cMaxima;
                    habitaciones.push(habitacion);
                }
            }
        });
        return (habitaciones.length) ? habitaciones : null;
    };

    $scope.getDestinos = function(){
        //get Destinos from server
        $scope.destinos = [{"id":0,"pais":"Afghanistan","ciudad":"Bascom"},{"id":1,"pais":"Ethiopia","ciudad":"Jeff"},{"id":2,"pais":"Thailand","ciudad":"Clarksburg"},{"id":3,"pais":"Slovakia","ciudad":"Springdale"},{"id":4,"pais":"Syria","ciudad":"Brambleton"},{"id":5,"pais":"Mali","ciudad":"Gorham"},{"id":6,"pais":"Nicaragua","ciudad":"Volta"},{"id":7,"pais":"Guernsey","ciudad":"Teasdale"},{"id":8,"pais":"Germany","ciudad":"Crumpler"},{"id":9,"pais":"Sweden","ciudad":"Orason"},{"id":10,"pais":"Belarus","ciudad":"Harrison"},{"id":11,"pais":"United Kingdom","ciudad":"Echo"},{"id":12,"pais":"Saudi Arabia","ciudad":"Strong"},{"id":13,"pais":"Saint Pierre &amp; Miquelon","ciudad":"Hartsville/Hartley"},{"id":14,"pais":"Georgia","ciudad":"Shelby"},{"id":15,"pais":"Kuwait","ciudad":"Gila"},{"id":16,"pais":"Ghana","ciudad":"Grantville"},{"id":17,"pais":"Congo","ciudad":"Urbana"},{"id":18,"pais":"Liechtenstein","ciudad":"Elliston"},{"id":19,"pais":"Djibouti","ciudad":"Bowden"},{"id":20,"pais":"Tajikistan","ciudad":"Valle"},{"id":21,"pais":"Grenada","ciudad":"Dalton"},{"id":22,"pais":"Jordan","ciudad":"Loomis"},{"id":23,"pais":"Gibraltar","ciudad":"Highland"},{"id":24,"pais":"Azerbaijan","ciudad":"Grapeview"},{"id":25,"pais":"Uzbekistan","ciudad":"Thynedale"},{"id":26,"pais":"Armenia","ciudad":"Odessa"},{"id":27,"pais":"Belgium","ciudad":"Snyderville"},{"id":28,"pais":"Togo","ciudad":"Condon"},{"id":29,"pais":"Czech Republic","ciudad":"Russellville"},{"id":30,"pais":"Honduras","ciudad":"Norvelt"},{"id":31,"pais":"Venezuela","ciudad":"Catharine"},{"id":32,"pais":"Bermuda","ciudad":"Duryea"},{"id":33,"pais":"Spain","ciudad":"Boyd"},{"id":34,"pais":"Turkmenistan","ciudad":"Wolcott"},{"id":35,"pais":"Montenegro","ciudad":"Dennard"},{"id":36,"pais":"Mauritius","ciudad":"Brenton"},{"id":37,"pais":"Guatemala","ciudad":"Biddle"},{"id":38,"pais":"Macau","ciudad":"Kapowsin"},{"id":39,"pais":"Bahrain","ciudad":"Marysville"},{"id":40,"pais":"Slovenia","ciudad":"Felt"},{"id":41,"pais":"Uganda","ciudad":"Frystown"},{"id":42,"pais":"Colombia","ciudad":"Fruitdale"},{"id":43,"pais":"Guam","ciudad":"Brooktrails"},{"id":44,"pais":"Greenland","ciudad":"Nile"},{"id":45,"pais":"Faroe Islands","ciudad":"Noxen"},{"id":46,"pais":"Switzerland","ciudad":"Stockwell"},{"id":47,"pais":"New Caledonia","ciudad":"Monument"},{"id":48,"pais":"Yemen","ciudad":"Cecilia"}]
    }

    $scope.createNewHotel = function(hotel){
        var habitacionesToSend = prepareHabitaciones();
        hotel.habitacion = habitacionesToSend;
        console.log(hotel);
    }

}
